#include<stdio.h>
int main()
{
	int a = 0, b = 0, c = 0;
	int month_day[12] = { 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 };
	scanf("%d%d%d", &a, &b, &c);
	if (a % 4 == 0 && a % 100 != 0)
	{
		if (b > 2&&b!=12)
			printf("%d", month_day[b - 2] + c );
		else if (b>2&&b==12)
			printf("%d", month_day[b - 2] + c+1);
			else
			printf("%d", month_day[b - 2] + c );
	}
	else
	{
		if(b>2)
			printf("%d", month_day[b - 2] + c + 1);
		else
			printf("%d", month_day[b - 2] + c );

	}
		
}
